/**
 * @file NetCenter.h
 * @Synopsis  Analyse xml,then dispatch pthead
 * @author JzeTech
 * @version jzetech
 * @date 2009-08-27
 */


 #ifndef _NETCENTER_H_
 #define _NETCENTER_H_



#include "mxml.h"
#include "netCtrl.h"
#include "netCommon.h"

/* --------------------------------------------------------------------------*/
/**
 * @Synopsis Register to server
 *
 * @Param FILE* fp
 *
 * @Returns  true or false
 */
/* ----------------------------------------------------------------------------*/
bool RegisterToServ(void* args);


/* --------------------------------------------------------------------------*/
/**
 * @Synopsis keep connecting with server via the heartbeat
 *
 * @Param FILE* fp
 */
/* ----------------------------------------------------------------------------*/
void HeartBeatFunc(void* args);

/* --------------------------------------------------------------------------*/
/**
  * @Synopsis
  *
  * @Param buffer
  * @Param bufLen
  * @Param hdrLen
  * @Param fd
  * @Param fp
  *
  * @Returns
  */
/* ----------------------------------------------------------------------------*/
int SendDataFunc(char* buffer, int bufLen, int hdrLen, FILE* fp, int fd);

/* --------------------------------------------------------------------------*/
/**
 * @Synopsis
 *
 * @Param buffer
 *
 * @Returns
 */
/* ----------------------------------------------------------------------------*/
/*
int GetCmdCode(char* buffer)
{
	    return *(int *)(buffer + 8);
}
*/
/* --------------------------------------------------------------------------*/
/**
 * @Synopsis
 *
 * @Param fd
 * @Param buffer
 */
/* ----------------------------------------------------------------------------*/
void AuthToVedioServ(int fd, char* buffer, int bufLen, int code);

/* --------------------------------------------------------------------------*/
/**
 * @Synopsis Client connect vedio server
 *
 * @Param fd
 * @Param buffer
 * @Param bufLen
 */
/* ----------------------------------------------------------------------------*/
void CliToVedioServ(int fd, char* buffer, int bufLen);

/* --------------------------------------------------------------------------*/
/**
 * @Synopsis
 */
/* ----------------------------------------------------------------------------*/
int IsTimeOut(struct timeval tim, int tmval);

/* --------------------------------------------------------------------------*/
/**
 * @Synopsis
 *
 * @Param buffer
 *
 * @Returns
 */
/* ----------------------------------------------------------------------------*/
//mxml_node_t* ParserXML(char* buffer, unsigned int len);

/**
 * @brief
 *
 * @param buffer
 *
 * @return
 */
//mxml_node_t* ParserSendXML(char* buffer);

/**
 * @brief
 *
 * @param buffer
 *
 * @return
 */
//mxml_node_t* ParserRecvXML(char* buffer);


/**
 * @brief
 *
 * @param buffer
 * @param len
 * @param flags
 *
 * @return
 */


/**
 * @brief
 *
 * @param args
 *
 * @return
 */
void NetMain(void* args);
void LocalNetMain(void* args);
void LocalNetMjpg(void* args);
void LocalNetMjpgCtrl(void* args);
void LocalSearchIPInfo(void *args);
//void LocalNetDispatch(void* args);
/**
 * @brief
 *
 * @param root
 * @param megaEyes
 */
//void GetRegInfo(mxml_node_t* root, MegaEyesHandle* megaEyes);


void GetRegInfo(mxml_node_t* root, RegInfo * info);
void StoreMsgOfRegInfo(mxml_node_t* node, RegInfo * info);
void StoreModuleOfRegInfo(mxml_node_t* node, RegInfo * info);
void StoreCameraOfRegInfo(mxml_node_t* node, RegInfo * info);
void StoreSchemeOfRegInfo(mxml_node_t* node, RegInfo * info);
void StoreAlarmInOfRegInfo(mxml_node_t* node, RegInfo * info);
void StoreAlarmOutOfRegInfo(mxml_node_t* node, RegInfo * info);
void StoreAnalyseOfRegInfo(mxml_node_t* node, RegInfo* info);
void StoreItemOfRegInfo(mxml_node_t *node, RegInfo *info);
int SendRedMsg(int fd);
void handleMsg();
void SendAlarmMsgToSer();
int SendStorageMsg();
int SendRegMsg(int fd);
void net_handler(int num);
#endif

